// @ts-nocheck
Page({

    /**
     * 页面的初始数据
     */
    data: {
        tricking_number: '',
        ExpressageData: {},
        steps: [],
        isReady: false,
    },
    callPhone: function () {
        wx.makePhoneCall({
            phoneNumber: '17845238261',
        });
    },
    copyData: function () {
        wx.setClipboardData({ data: this.data.tricking_number })
    },
    goBack: function () {
        wx.navigateBack()
    },
    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
        const ExpressageNumber = options.ExpressageNumber
        this.trackExpress(ExpressageNumber as string)
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },
    trackExpress: function (tricking_number: string) {
        wx.request({
            method: "POST",
            url: "https://www.yto.net.cn/ec/order/gwWaybillInfoList",
            data: [tricking_number],
            header: {
                'content-type': 'application/json',
                "Cookie": 'i18n_redirected=zh-cn; acw_tc=6f842c0f17356685912614232e79a635fecfc75c38c7cc0e7ac68befc2; Hm_lvt_986cf607d44c3333e9a678297feca67a=1735668603; HMACCOUNT=E0EA2ED03BA6998B; isAgreeCookie=1; jwt-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAAEWRX2vCMBTFv0te5-Tmb5O-zbZjDnHCdC_rHqoNLqBNSdLhEL_7slQR8nLPOffmB-eM9KlHOc6oJAJTpSbID1uUo3ONemd_TKvdsjnqGuU1ej_6hd2bbnU1ajSpkbeD243-qkjK4LXrbjs4k4yTdD2Z-hR01765fWFb7WPk8yuqUWu6MG_TSsodmm5_n5w93MPt4JpgbBdnRglASvuQ0Nbm-i8Bwh8Bx7cGkhOaYzUVDyBzgHSxGcK3dSaY-91_7oSAM65ACoaZzIgAmQkV7aPdmoP-MC4MzeGKmlHC5QzPqGJViYFx4FIAYJhhTIuSVfBcEUYwjwbDXJRPhPOKlhUjBVY8G1H6fv3bj9h6lyTb627eLowPN7hRGVkvaIJME1JtXAiVajPex9oW89fNcvqyQZc_Q-WEHdoBAAA.Ku4qPH6Cyu7y1dNc07-f0el9E_pFvBNeEvviR9FhTis; jwt-token-expires=1735669399652; Hm_lpvt_986cf607d44c3333e9a678297feca67a=1735669400',
                "jwt-token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAAEVRXU-DMBT9L311mn638LYBKoqoyeZMxBgmzaxOStpipsb_Litb9njPOb09555foLYdiJGgSMqICDwBrl-BGPxWoLPmSzfKlvWnqkBcgUV5Xd4uywpMKuBMb19H-C4JSO-UbQ9SJCRlmEjMUSDV1qu2ubXrxDTKDZKn5wEdsLr1eROeBN2mbtfHyZrNUdz0tvbatMNMJQxa5wuz1u1c73_FELNTSE4RmSMZwygm-ExgcgKHAYaNde_fjNVeH_fufAcLSLAISk4RlQJzKAWPBtp0qtWjQ5Pn6c-7m9arj6h4f-TbwnN480bvH2fTsP3TrPRGPWjr-3qzjyUIZnKGZiSiWYogZZBJDiGCM4RIktIMnmeYYsQGgiLG0ylmLCNpRnGCIiZG2103_-7GkOp1vFRIfgAvli_LLLmczgO385w3hXb-EHJExsx_YAJ07fetc8h2rWvnhtaL_GpRnl0uwN8_2IWLZRkCAAA.LTFIvEQe75b3YlJmm4py27meFH_l0lfpLfCSUkPfY_w"
            },
            success: (res) => {
                if (res.data[0]) {
                    const ExpressageResData = res.data[0]
                    const ExpressageData = []
                    const formattedData = ExpressageResData.waybillProcessInfo.map((item, index) => {
                        const data = {
                            text: item.opTime,
                            desc: item.description
                        }
                        ExpressageData.push(data)
                    });

                    this.setData({
                        ExpressageData: formattedData,
                        tricking_number: ExpressageResData.waybillNo,
                        steps: ExpressageData
                    })
                    this.setData({ isReady: true })
                    return
                }
                wx.showModal({
                    title: '获取数据失败',
                    content: '是否返回查询页面?',
                    success(res) {
                        if (res.confirm) {
                            wx.navigateBack()
                        }
                    }

                })
            },
            fail: function (req) {
                wx.showModal({
                    title: '获取数据失败',
                    content: '是否返回查询页面?',
                    success(res) {
                        if (res.confirm) {
                            wx.navigateBack()
                        }
                    }

                })
                this.setData({ isReady: true })
            }
        })

    },
})